package org.jvcs.common;

import java.util.*;
import java.io.*;

public class GeneralUtils {

	public static int getRandomInt(int start, int end) {
	
		Random randomGenerator = new Random();
		boolean foundNo = false;
		int selNo = 0;
		while (!foundNo) {
			selNo = randomGenerator.nextInt(end);
			if (selNo > start) 
				break;
		}
		return selNo;
	}
	
	
	public static boolean runFileTransferServer(int portNo) {
		try {
			String java_cmd = "java -cp ";
			String jvcs_bin = System.getenv(G.JVCS_BIN);
			String jvcs_sa_program = "ServerFileTransfer";
			String filePath = "c:/temp/TEST-SERVER.txt";
			String command = java_cmd + jvcs_bin + " " + jvcs_sa_program + " "+ portNo + " "+filePath;
			Process child = Runtime.getRuntime().exec(command);
			child.waitFor();
			System.out.println(child.exitValue());


		} catch (Exception e) {
			osr.pl("Error in the run of FileTransfer Server"+e.toString());
		}
		return true;
	}
}